package com.iot.manage.service;

import com.alibaba.fastjson.JSONObject;
import com.iot.manage.dao.DeviceMapper;
import com.iot.manage.pojo.Device;
import com.iot.manage.pojo.SysCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceService {

    @Autowired
    private DeviceMapper deviceMapper;

    public List<Device> findDevicesList(String query, int pagenum, int pagesize) {
        return deviceMapper.findDevicesList(query,pagesize * (pagenum - 1),pagesize * pagenum);
    }

    public int countDevicesList(String query) {
        return deviceMapper.countDevicesList(query);
    }

    public List<SysCode> findDtypeCodeList() {
        return deviceMapper.findDtypeCodeList();
    }

    public List<SysCode> findDeviceStatusList() {
        return deviceMapper.findDeviceStatusList();
    }

    public List<SysCode> findModelCodeList() {
        return deviceMapper.findModelCodeList();
    }

    public List<SysCode> findCompanyCodeList() {
        return deviceMapper.findCompanyCodeList();
    }

    public List<SysCode> findGatewayCodeList() {
        return deviceMapper.findGatewayCodeList();
    }

    public List<SysCode> findParentCodeList() {
        return deviceMapper.findParentCodeList();
    }

    public void addDeviceInfo(JSONObject params) {
        deviceMapper.addDeviceInfo(params);
    }

    public Device findDeviceInfoById(String params) {
        return deviceMapper.findDeviceInfoById(params);
    }

    public void updateDeviceInfo(JSONObject params) {
        deviceMapper.updateDeviceInfo(params);
    }

    public void removeDeviceInfo(String deviceId) {
        deviceMapper.removeDeviceInfo(deviceId);
    }

    public void updateDeviceParentCodeInfo(JSONObject params) {
        deviceMapper.updateDeviceParentCodeInfo(params);
    }

    public int countDeviceParentByCode(String deviceCode) {
        return deviceMapper.countDeviceParentByCode(deviceCode);
    }

    public void updateDeviceInfoParent(String deviceCode) {
        deviceMapper.updateDeviceInfoParent(deviceCode);
    }

    public void deleteRelevancyAreaById(String deviceId) {
        deviceMapper.deleteRelevancyAreaById(deviceId);
    }
}
